<?
	include '../model/database.php';
	include '../model/xl_dia_diem.php';
	include '../model/xl_dia_diem_da_den.php';
	
	$xl_dia_diem = new xl_dia_diem();
	$xl_dia_diem_da_den = new xl_dia_diem_da_den();
	
	$data = array("success"=>false);
	$madiadiem = $_REQUEST['placeId'];
	$manguoidung = $_REQUEST['userid'];
	
	
	
	$iview = $xl_dia_diem_da_den->isView($madiadiem,$manguoidung);
	if($iview){
		$tongsonguoiden = $xl_dia_diem->visitCount($madiadiem);
		$data = array("success"=>true,"visit"=>$tongsonguoiden);
	}else{
		if($xl_dia_diem->updateVisit($madiadiem) && $xl_dia_diem_da_den->themDiaDiem($madiadiem,$manguoidung)){
			$tongsonguoiden = $xl_dia_diem->visitCount($madiadiem);
			$data = array("success"=>true,"visit"=>$tongsonguoiden);
		}
	}
	echo json_encode($data);
?>